Shell实现控制台确认交互

1
2
3
4
5
6
7
8
9
read -r -p "Are you sure? [y/N] " response
case "$response" in
[yY][eE][sS]|[yY])
do_something
;;
*)
do_something_else
;;
esac

参考文档: https://stackoverflow.com/questions/3231804/in-bash-how-to-add-are-you-sure-y-n-to-any-command-or-alias

Donate - Support to make this site better.
捐助 - 支持我让我做得更好.